﻿#ifndef JZNODE_PARAM_VALUE_WIDGET_H_
#define JZNODE_PARAM_VALUE_WIDGET_H_

#include <QLabel>
#include <QToolButton>
#include <QLineEdit>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QPushButton>
#include <functional>

//JZPropertyFocusEventFilter
class JZPropertyFocusEventFilter : public QObject
{
public:
    JZPropertyFocusEventFilter(QObject *parent);
    virtual bool eventFilter(QObject *object, QEvent *event) override;
};

//JZPropertyWidget
class JZProperty;
class JZPropertyWidget : public QWidget
{
    Q_OBJECT

public:
    JZPropertyWidget(JZProperty *prop);
    
    JZProperty* JZPropertyWidget::prop();
    virtual QVariant value() = 0;

protected:
    JZProperty* m_prop;
};

//JZPropertyLineWidget
class JZPropertyLineWidget : public JZPropertyWidget
{
    Q_OBJECT

public:
    JZPropertyLineWidget(JZProperty *prop);

    virtual QVariant value();

protected:
    QLineEdit* m_line;
};

//JZPropertyComboBoxWidget
class JZPropertyComboBoxWidget : public JZPropertyWidget
{
    Q_OBJECT

public:
    JZPropertyComboBoxWidget(JZProperty *prop, QVariantList valueList,QStringList dispList);

    virtual QVariant value();

protected:
    QComboBox* m_box;
    QVariantList m_valueList;
    QStringList m_dispList;
};

//JZPropertySpinBoxWidget
class JZPropertySpinBoxWidget : public JZPropertyWidget
{
    Q_OBJECT

public:
    JZPropertySpinBoxWidget(JZProperty *prop);

    virtual QVariant value();
    QSpinBox* spinBox();

protected:
    QSpinBox* m_box;
};

//JZPropertyDoubleSpinBoxWidget
class JZPropertyDoubleSpinBoxWidget : public JZPropertyWidget
{
    Q_OBJECT

public:
    JZPropertyDoubleSpinBoxWidget(JZProperty *prop);

    virtual QVariant value();
    QDoubleSpinBox* spinBox();

protected:
    QDoubleSpinBox* m_box;
};

//JZPropertyDialogWidget
class JZPropertyDialogWidget : public JZPropertyWidget
{
    Q_OBJECT

public:
    JZPropertyDialogWidget(JZProperty *prop);

    virtual QVariant value();
    std::function<QVariant(JZPropertyDialogWidget*)> showFunction;

protected slots:
    void onShowDialog();

protected:
    QLineEdit* m_line;
    QPushButton* m_btn;
    QVariant m_value;
};


#endif